<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
    <input type="text" v-model="num1">
    <input type="text" v-model="num2">
    <input type="button" value="加" @click="f('+')">
    <input type="button" value="减" @click="f('-')">
    <input type="button" value="乘" @click="f('*')">
    <input type="button" value="除" @click="f('/')">
    <h1>结果:{{result}}</h1>
</div>
<!--引入VUE-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el:"div",
        data:{
            result:"",
            num1:"",
            num2:"",
        },
        methods:{
          f:function (x) {
              //把两个数值和x符号拼接在一起 通过eval方法进行计算 把结果给到result
              v.result =eval(v.num1+x+v.num2)
          }
        }
    })
</script>
</body>
</html>